package com.zhiyou.app.common.exception;

import com.xinchao.components.resp.ResponseCode;
import com.xinchao.components.resp.ResponseCodeDefault;
import com.zhiyou.app.common.vo.resp.BizResponseCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class BizException extends RuntimeException{
    /**
     * code
     */
    private String code;
    /**
     * msg
     */
    private String msg;

    public BizException(String msg) {
        super(msg);
        this.code = ResponseCodeDefault.FAILED.getCode();
        this.msg = msg;
    }

    public BizException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BizException(ResponseCode responseCode) {
        super(responseCode.getMsg());
        this.code = responseCode.getCode();
        this.msg = responseCode.getMsg();
    }

    public BizException(BizResponseCode responseCode) {
        super(responseCode.getMsg());
        this.code = responseCode.getCode();
        this.msg = responseCode.getMsg();
    }
}
